package com.listener;

import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

public class MyHttpSessionListener implements HttpSessionListener {
    @Override
    public void sessionCreated(HttpSessionEvent se) {
        HttpSession session = se.getSession();
        //session被创建时，统一给定时长
//        session.setMaxInactiveInterval(5);
        //HttpSessionEvent se：Session事件对象 可以拿到当前被监听的Session
        System.out.println("Session被创建" + session.getId());
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent se) {
        System.out.println("Session被销毁" + se.getSession().getId());
    }
}
